const chalk = require('chalk');
const inquirer = require('inquirer');
// 当前目录
const dirPath = `${process.cwd()}/`;
const fileOp = require('../lib/file.js');
// 图片上传命令选择
module.exports = (program) => {
    program
    .command('upload')
    .alias('up')
    .description('上传图片，命令：uap up')
    .action(option => {
        const promps = [];
        promps.push({
            type: 'list',
            name: 'upload',
            message: '请选择单个图片上传或全部图片上传',
            choices: [{
                name: '单个图片上传',
                value: 'single',
            },
            {
                name: '多个图片上传',
                value: 'more',
            },
            {
                name: '全部图片上传',
                value: 'all',
            },
            ],
        });
        inquirer.prompt(promps).then(function(answers) {
            if (answers.upload === 'single') {
                console.log(chalk.red('执行单个图片上传，需要输入图片名称'));
               fileOp.getSingleImg(dirPath);
                return;
            }
            if (answers.upload === 'more') {
                console.log(chalk.red('请选择多个图片上传'));
                fileOp.getMoreImg(dirPath);
                return;
            }
            if (answers.upload === 'all') {
                console.log(chalk.red('全部图片上传ing...'));
                fileOp.getAllImg(dirPath);
                // const imgArr = fileOp.getImageFiles(dirPath);
                // fileOp.allUpload(imgArr, dirPath);
                return;
            }
        });
    })
}
